// [[ OnflowGenerator File UUID: b560e1ff9b0d46d58c53c5a44557a515  ]]
package com.itdct.onflow.system.file.controller

import com.itdct.onflow.core.type.*
import com.itdct.onflow.core.vo.KeyLabelValueVo
import com.itdct.onflow.core.vo.RespPageVo
import com.itdct.onflow.core.vo.RespVo
import com.itdct.onflow.system.common.base.BaseSysController
import com.itdct.onflow.system.file.qo.SysFileEditQo
import com.itdct.onflow.system.file.qo.SysFileSearchQo
import com.itdct.onflow.system.file.qo.SysFileUploadQo
import com.itdct.onflow.system.file.service.SysFileService
import com.itdct.onflow.system.file.vo.SysFileDetailVo
import com.itdct.onflow.system.file.vo.SysFileListVo
import com.itdct.onflow.system.file.vo.SysFileUploadVo
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

/**
 * @author DCTANT
 * @date 2025-09-23 16:16:15
 * @version 1.0
 * @description 系统文件管理接口控制
 */
@Tag(name = SysFileController.moduleName)
@RestController
@RequestMapping(value = ["/sysFile"], produces = [MediaType.APPLICATION_JSON_VALUE], method = [RequestMethod.POST])
class SysFileController(
    val sysFileService: SysFileService
) : BaseSysController() {
    companion object {
        const val moduleName = "系统文件管理"
    }

    @Operation(summary = moduleName + "添加")
    @PostMapping("/add.adw")
    fun add(@RequestBody @Validated(Add::class) qo: SysFileEditQo): RespVo<Long> {
        return sysFileService.add(qo, getContext())
    }

    @Operation(summary = moduleName + "更新")
    @PostMapping("/update.adw")
    fun update(@RequestBody @Validated(Update::class) qo: SysFileEditQo): RespVo<Unit> {
        return sysFileService.update(qo, getContext())
    }

    @Operation(summary = moduleName + "删除")
    @PostMapping("/delete.adw")
    fun delete(@RequestBody @Validated(Delete::class) qo: SysFileEditQo): RespVo<Unit> {
        return sysFileService.delete(qo, getContext())
    }

    @Operation(summary = moduleName + "详情")
    @PostMapping("/detail.adw")
    fun detail(@RequestBody @Validated(Detail::class) qo: SysFileSearchQo): RespVo<SysFileDetailVo> {
        return sysFileService.detail(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/page.adw")
    fun page(@RequestBody @Validated(Page::class) qo: SysFileSearchQo): RespPageVo<SysFileListVo> {
        return sysFileService.page(qo, getContext())
    }

    @Operation(summary = moduleName + "上传")
    @PostMapping("/upload.adw")
    fun upload(qo: SysFileUploadQo): RespVo<SysFileUploadVo> {
        return sysFileService.uploadFile(qo, getContext())
    }

    @Operation(summary = moduleName + "下载")
    @GetMapping("/download.adw")
    fun download(@RequestParam(name = "id", defaultValue = "0") id: Long = 0L) {
        sysFileService.download(id, getContext())
    }

// [[ OnflowGenerator Range (- selectFunctions -) Start ]]

    @Operation(summary = moduleName + "文件名下拉选")
    @PostMapping("/selectFileNameList.adw")
    fun selectFileNameList(@RequestBody qo: SysFileSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysFileService.selectFileNameList(qo, getContext())
    }

// [[ OnflowGenerator Range (- selectFunctions -) End ]]
}